package com.wao.file.service;

import com.wao.base.security.tenant.TenantIdentifierResolver;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.PostConstruct;

public abstract class AbstractFileStorage implements FileStorage {

    @Value("${wao.file.qiniu.bucket:}")
    protected String bucket;

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    @PostConstruct
    public void afterPropertiesSet() {
        if (StringUtils.isBlank(this.bucket)) {
            this.bucket = TenantIdentifierResolver.getCurrentTenantIdentifier();
        }
    }
}
